package com.cf.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author lzqinga@126.com
 * @Date 2024/12/3  10:29
 */
public class DateUtil {

    // 创建SimpleDateFormat对象，定义目标格式
    public final static String YYYYMMDD = "yyyy-MM-dd";
    public final static String YYYYMMDDHHMMSS = "yyyy-MM-dd HH:mm:ss";

    public static String date2Str(Date date, String type){
        SimpleDateFormat sdf = new SimpleDateFormat(type);
        String formattedDate = sdf.format(date);
        return formattedDate;
    }
}
